<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.6 of March 3, 2008 on April 1, 2009 at 1:49:21 pm</time-stamp>


<class>
<name>RetailerAppModel</name>
<environment>SupplyChain</environment>
<super>UI.SimpleDialog</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>reorderPoint currentInventoryList inventoryList retailer currentOrder itemList </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>SupplyChain.RetailerAppModel class</class-id> <category>interface specs</category>

<body package="SupplyChain" selector="windowSpec">windowSpec
	"Tools.UIPainter new openOnClass: self andSelector: #windowSpec"

	&lt;resource: #canvas&gt;
	^#(#{UI.FullSpec} 
		#window: 
		#(#{UI.WindowSpec} 
			#label: 'Retailer GUI' 
			#bounds: #(#{Graphics.Rectangle} 640 512 1055 824 ) ) 
		#component: 
		#(#{UI.SpecCollection} 
			#collection: #(
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 3 295 ) 
					#name: #retailerGUI 
					#label: 'SuperPOS v0.1' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 341 296 ) 
					#name: #retailerName 
					#label: 'Retailer Name' ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 29 216 110 239 ) 
					#name: #edit 
					#model: #editButtonClick 
					#label: 'Edit Item' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 164 224 245 247 ) 
					#name: #sell 
					#model: #sellItemClick 
					#label: 'Sell Item' 
					#defaultable: true ) 
				#(#{UI.GroupBoxSpec} 
					#layout: #(#{Graphics.Rectangle} 147 96 266 152 ) 
					#name: #GroupBox2 ) 
				#(#{UI.GroupBoxSpec} 
					#layout: #(#{Graphics.Rectangle} 147 159 266 215 ) 
					#name: #GroupBox3 ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 160 101 ) 
					#name: #marketValue 
					#label: 'Total Market Value' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 187 122 ) 
					#name: #moneyMarket 
					#label: '$00.00' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 148 163 ) 
					#name: #inventoryCost 
					#label: 'Total Cost of Inventory' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 187 184 ) 
					#name: #moneyInv 
					#label: '$00.00' ) 
				#(#{UI.GroupBoxSpec} 
					#layout: #(#{Graphics.Rectangle} 147 32 266 88 ) 
					#name: #GroupBox1 ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 187 60 ) 
					#name: #moneyInventory 
					#label: '$00.00' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 152 37 ) 
					#name: #totalValue 
					#label: 'Total Inventory Value' ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 162 279 259 302 ) 
					#name: #changeSellPolicy 
					#model: #changePolicyClick 
					#label: 'Change Sell Policy' 
					#defaultable: true ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 282 5 ) 
					#name: #itemsOnOrder 
					#label: 'Items On Order' ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 10 7 ) 
					#name: #currInventory 
					#label: 'Current Inventory' ) 
				#(#{UI.SequenceViewSpec} 
					#layout: #(#{Graphics.Rectangle} 9 30 131 214 ) 
					#name: #inventoryList 
					#model: #inventoryList 
					#useModifierKeys: true 
					#selectionType: #highlight ) 
				#(#{UI.SequenceViewSpec} 
					#layout: #(#{Graphics.Rectangle} 281 30 403 214 ) 
					#name: #itemsOnOrderList 
					#model: #itemList 
					#useModifierKeys: true 
					#selectionType: #highlight ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 30 243 111 266 ) 
					#name: #addItemButton 
					#model: #addButtonClick 
					#label: 'Add Item' 
					#defaultable: true ) ) ) )</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerAppModel class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	^super new initialize.</body>

<body package="SupplyChain" selector="withRetailer:">withRetailer: aRetailer
	| this |
	this := super new initialize.
	this retailer: aRetailer.
	^this.</body>
</methods>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<comment>
<class-id>SupplyChain.RetailerAppModel</class-id>
<body>Main GUI for Retailer, contains list of inventory, items on order...

Instance Variables:
	retailer	&lt;Retailer&gt;					the retailer this is controlling
	currentOrder	&lt;Order&gt;			the current/next order which will be sent
	inventoryList	&lt;SelectionInList&gt;	list of inventory items
	itemList	&lt;SelectionInList&gt;			list of items on the order</body>
</comment>

<methods>
<class-id>SupplyChain.RetailerAppModel</class-id> <category>actions</category>

<body package="SupplyChain" selector="addButtonClick">addButtonClick
	| item |
	item := RetailerEditItemDialog showNewItem.
	
	item notNil ifTrue:
		[
		retailer inventory addItem: item.
		itemList changed].

	^self</body>

<body package="SupplyChain" selector="changePolicyClick">changePolicyClick
	"What happens when a user clicks the change policy"

	Transcript show: 'Implement me!'.</body>

<body package="SupplyChain" selector="editButtonClick">editButtonClick
	"What happens when the user clicks the edit button"

	inventoryList selection notNil
		ifTrue:
			[ | item dialog |
			item := inventoryList selection.
			dialog := RetailerEditItemDialog new.
			dialog model: item.
			dialog open ifTrue:
				[ itemList changed ].
			].</body>

<body package="SupplyChain" selector="sellItemClick">sellItemClick
	"What happens when a user clicks the sell button"

	inventoryList selection notNil ifTrue:
	[	| item |
		item := inventoryList selection.
		retailer sellItem: item.
	]</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerAppModel</class-id> <category>accessing</category>

<body package="SupplyChain" selector="currentInventoryList">currentInventoryList
	^currentInventoryList</body>

<body package="SupplyChain" selector="currentInventoryList:">currentInventoryList: anObject
	currentInventoryList := anObject</body>

<body package="SupplyChain" selector="itemList">itemList
	^itemList</body>

<body package="SupplyChain" selector="itemList:">itemList: anObject
	^itemList := anObject</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerAppModel</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize the variables"

	super initialize.
	retailer isNil ifTrue:
		[ retailer := Retailer new].
	(inventoryList := SelectionInList new) listHolder: ((UI.AspectAdaptor subject: (retailer inventory) sendsUpdates: true) forAspect: #items).
	currentOrder isNil ifTrue:
		[ currentOrder := Order new].
	(itemList := SelectionInList new) listHolder: ((UI.AspectAdaptor subject: currentOrder sendsUpdates: true) forAspect: #items).</body>
</methods>

<methods>
<class-id>SupplyChain.RetailerAppModel</class-id> <category>aspects</category>

<body package="SupplyChain" selector="inventoryList">inventoryList
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^inventoryList isNil
		ifTrue:
			[inventoryList := SelectionInList new]
		ifFalse:
			[inventoryList]</body>
</methods>

</st-source>
